package estates.model;

import java.util.HashMap;
import java.util.List;
import javax.persistence.*;


public class DekoratorGruntowy extends Dekorator {

  private String typ_gruntu;
  private String klasa_gruntu;
  private int numer_dzialki;


      @Override
    public List<User> getInterestedUsers() {
        return element.getInterestedUsers();
    }

    @Override
    public boolean setInterestedUser(User u) {
        element.setInterestedUser(u);
        return true;
    }

    @Override
    public boolean update(HashMap<String,Object> hm) {
        return element.update(hm);
    }
  public DekoratorGruntowy() {
  }

  public DekoratorGruntowy(Estate e) {
    super(e);
  }

  public String getTypGruntu() {
    return typ_gruntu;
  }

  public String getKlasaGruntu() {
    return klasa_gruntu;
  }

  public int getNumerDzialki() {
    return numer_dzialki;
  }

  @Override
  public void dekoruj(HashMap<String, Object> hm) {
    if (hm.containsKey("typ_gruntu")) {
      this.typ_gruntu = (String) hm.get("typ_gruntu");
    }
    if (hm.containsKey("klasa_gruntu")) {
      this.klasa_gruntu = (String) hm.get("klasa_gruntu");
    }
    if (hm.containsKey("numer_dzialki")) {
      this.numer_dzialki = (Integer) hm.get("numer_dzialki");
    }
    this.element.dekoruj(hm);
  }

  @Override
  public boolean equals(Object e) {
    if (!(e instanceof DekoratorGruntowy)) {
      return false;
    }
    return element.equals(e);
  }

  @Override
  public int hashCode() {
    int hash = 3;
    hash = 71 * hash + this.element.hashCode();
/*    hash = 71 * hash + (this.typ_gruntu != null ? this.typ_gruntu.hashCode() : 0);
    hash = 71 * hash + (this.klasa_gruntu != null ? this.klasa_gruntu.hashCode() : 0);
    hash = 71 * hash + this.numer_dzialki;*/
    return hash;
  }

  @Override
  public String toString() {
    String pom = element.toString();
    pom += "&typ_gruntu=" + typ_gruntu +
            "&klasa_gruntu=" + klasa_gruntu +
            "&numer_dzialki=" + numer_dzialki;
    return pom;
  }

  @Override
  public HashMap<String, String> obliczSrednieOceny() {
	 return element.obliczSrednieOceny();
  }


    /*@Override
    public List<User> getInterestedUsers() {
        return element.getInterestedUsers();
    }

    @Override
    public boolean setInterestedUser(User u) {
        element.setInterestedUser(u);
        return true;
    }*/
}
